class Solution {
public:
    long pre = INT_MIN;
    bool isValidBST(TreeNode* root)
    {
        if (root == nullptr)
            return true;
        if (!isValidBST(root->left))
            return false;
        if (root->val <= pre)
            return false;
        pre = root->val;
        if (!isValidBST(root->right))
            return false;
        return true;

    }
};